﻿using Assets.Scripts.DL.Mgrs;
using Unity.VisualScripting;
using UnityEngine;

namespace Assets.Scripts.DL.ComponentScripts {
	//斯安威斯坦
	public class DavidEffect : MonoBehaviour {
		[SerializeField] ParticleSystem _particleSystem;
		public static DavidEffect Instance { get; private set; }
		GameObject Player;
		private void Awake() {
			Instance = this;
		}
		private void Update() {
			if (Time.timeScale < 0.5f && !_particleSystem.isPlaying) {
				PlayEffect();
				if (Time.timeScale < 0.2f) //0.5是弹反顿帧
					ScreenEffectMgr.Instance.BrokenEffect(5);
			}
			else if (Time.timeScale > 0.9f) {
				_particleSystem.Stop();
			}
		}
		//弹反用
		public void PlayEffect() {
			if (Player == null) {
				Player = GameObject.FindWithTag("Player");
			}
			transform.position = Player.transform.position;
			_particleSystem.Play();
		}
	}
}
